package com.zsw.talk;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class ClientHandler extends SimpleChannelInboundHandler<String>{

	private final static Logger LOG = LoggerFactory.getLogger(ClientHandler.class);
	
	@Override
	public void channelRead0(ChannelHandlerContext ctx, String body) throws Exception {
		LOG.info("Someone:{}", body);
        Client.showRecivedMsg(body);
	}
	@Override
	public void channelActive(ChannelHandlerContext ctx) {
		LOG.info("客户端连接服务器，开始发送数据……");
	}
	@Override
	public void channelInactive(ChannelHandlerContext ctx) throws Exception {
		super.channelInactive(ctx);
		LOG.info("客户端断开服务器");
		System.exit(-1);
	}
}
